package com.jbh.apilibrary.bean

import com.google.gson.Gson
import okhttp3.MediaType
import okhttp3.RequestBody
import okio.BufferedSink
import java.nio.charset.Charset

open class BaseRequest(private val post:HashMap<String, Any>?) :RequestBody() {


    override fun contentType(): MediaType {
        return MediaType.parse("application/json; charset=utf-8")
    }

    override fun writeTo(sink: BufferedSink?) {
        sink!!.apply {
            val content = Gson().toJson(post)
            println("[post] - > content  = $content ")
            writeString(content , Charset.defaultCharset())
        }
    }
}